package cn.itcast.message.xt;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
public abstract class IoTMessage implements Serializable {

    public static Class<?> getMessageClass(int messageType) {
        return messageClasses.get(messageType);
    }
    private int messageType;

    public abstract int getMessageType();

    public static final int IoTLoginRequestMessage = 1;
    public static final int IoTLoginResponseMessage = 2;

    private static final Map<Integer, Class<?>> messageClasses = new HashMap<>();
    static {
        messageClasses.put(IoTLoginRequestMessage, IoTLoginRequestMessage.class);
        messageClasses.put(IoTLoginResponseMessage, IoTLoginResponseMessage.class);
    }
}
